//
//  HealthyViewModel.m
//  HonlivApp
//
//  Created by admin on 2017/6/26.
//  Copyright © 2017年 honliv. All rights reserved.
//

#import "HealthyViewModel.h"
#import "HealthyInfoModel.h"
//所有体检记录
static NSString *const healthy_url = @"api/Account/GetMyMainExamined";

@implementation HealthyViewModel

-(void)getHealthyDatasSuccess:(void (^)(NSArray *))completion{
    NSDictionary *info = @{@"patient_id":[User currentUser].patientId};
    NSString *url = [NSString stringWithFormat:@"%@%@",HOSPITAL_URL,healthy_url];
    [NetWorker getCommonDatasWithURLStr:url body:info success:^(id result) {
        NSLog(@"%@",result);
        NSArray *array = [JsonHelper arrayWithJsonString:result[@"Entity"]];
        NSMutableArray *modelArray = [NSMutableArray array];
        for (int i=0; i<array.count; i++) {
            NSDictionary *dic = array[i];
            HealthyInfoModel *model = [HealthyInfoModel setHealthyInfoWithDictionary:dic];
            [modelArray addObject:model];
        }
        completion(modelArray);
    } failure:^(id result) {
        completion([NSArray array]);
        [SVProgressHUD showErrorWithStatus:@"您目前还没有健康信息"];
    }];

}

@end
